define(["text!/components/template/station_lv1.html","/components/lv1_btn.js","sdata"], function(template,lv1_btn,sdata) {
    console.log('station_lv1 define')
    let config = ['s01','s02','a01','a02']
    let vueExtend = function(resolve, reject) {
        console.log('station_lv1 resolve')
        resolve({
            template: template,
            components:{
                //加载子组件lv1_btn
                'lv1_btn':lv1_btn.vueExtend
            },
            data: function() {
                console.log('station_lv1 data',sdata)
                let rootNode = this.$root.$el;
                return { 
                    a01:0,
                    a02:0,
                    s01:0,
                    s02:0,
                    blue_display:false,
                    green_display:true,
                    red_display:false,
                    yellow_display:false,
                    name: rootNode.getAttribute('id'),
                    tagData: sdata.getTagDataByTag(rootNode.getAttribute('data-opt-tag'))
                };
            },
            methods:{
                changeStatus:function() {
                    console.log('changestatus')
                    // sdata.getTagDataByTag(this.$root.$el.getAttribute('data-opt-tag')).set('a01',3)
                    // this.$set(this.tagData,'a01',4)
                    this.a01 = 5
                    console.log(this.a01)
                },
                show:function () {
                    console.log('show')
                    if(this.a01 == 1 && this.a02 ==0 && this.s01 == 0 && this.s02 ==0)
                    {
                        this.green_display = true
                        this.blue_display = false
                        this.red_display = false
                        this.yellow_display = false
                    }else if(this.a01 == 0 && this.a02 == 1 && this.s01 == 0 && this.s02 == 0)
                    {
                        this.green_display = false
                        this.blue_display = false
                        this.yellow_display = true
                        this.red_display = false
                    }else if(this.a01 == 0 && this.a02 == 0 && this.s01 == 1 && this.s02 == 0)
                    {
                        this.green_display = false
                        this.blue_display = false
                        this.yellow_display = false
                        this.red_display = true
                    }else{
                        this.green_display = false
                        this.blue_display =true
                        this.red_display = false
                        this.yellow_display = false
                    }
                }
            },
            watch:{
                a01 : function(){
                    this.show()
                },
                a02 : function(){
                    this.show()
                },
                s01 : function(){
                    this.show()
                },
                s02 : function(){
                    this.show()
                }
            },
            beforeCreate: function() {
                console.log('station_lv1 before created:'+this)
                let rootNode = this.$root.$el
                let deviceTag = rootNode.getAttribute('data-opt-tag')
                console.log('station_lv1 deviceTag:',deviceTag)
                // sdata.setTagMapWithAttrList(deviceTag,config)
                sdata.addToVueRefMap(deviceTag,this)
                console.log(this.$store)
            }
        })
    }
    
    return{vueExtend,config}
})